﻿
#include <iostream>

using namespace std;
int main()
{
int pai = 0, lie = 0;
if (fopen("data.txt", "r") != NULL) { 
    printf("您已输入数据，是否清零重输？是请输入1或否请输入0。"); 
    if (getchar() == '0')return 0;
}
FILE* fp = fopen("data.txt", "w");
printf("欢迎使用用药助手药柜录入向导！\n提示：输入后按回车确认。\n");
printf("请输入药柜排数："); scanf("%d", &pai);
printf("请输入药柜列数："); scanf("%d", &lie);
fputc(pai,fp);
fputc(lie, fp);
 for (int a = 1; a <= pai; a++) 
 {
     printf("请录入第%d排的药名！\n", a);
        for (int b = 1; b <= lie; b++) 
        {
            char name[10] = {0};
             printf("%d排%d列：",a,b); scanf("%s",name);             
             strcat(name, "#");
             fputs(name, fp);
        }
  }
 printf("完成啦！已在程序目录生成data.txt文件。");
 system("pause");
 fclose(fp);
 return 0;
}

